using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace QFramework.Example
{
    public class ExpUpgradeItem
    {

        public string Key
        {
            get;
            private set;
        }

        public string Description
        {
            get;
            private set;
        }

        public bool UpgradeFinish
        {
            get;
            set;
        } = false;

        private Action<ExpUpgradeItem> ActionUpgrade;

        private Func<ExpUpgradeItem,bool> FuncCondition;

        public void Upgrade(ExpUpgradeItem item)
        {
            ActionUpgrade?.Invoke(item);
        }

        public bool UpgradeCondition(){
            if(FuncCondition != null)
            {
                return !UpgradeFinish && FuncCondition.Invoke(this);
            }

            return !UpgradeFinish;
        }


        public ExpUpgradeItem OnKey(string key)
        {
            Key = key;
            return this;
        }

        public ExpUpgradeItem OnDescription(string description)
        {
            Description = description;
            return this;
        }

        public ExpUpgradeItem OnUpgrade(Action<ExpUpgradeItem> action)
        {
            ActionUpgrade = action;
            return this;
        }

        public ExpUpgradeItem OnCondition(Func<ExpUpgradeItem,bool> func)
        {
            FuncCondition = func;
            return this;
        }

    }
}
